<?php
class UserAction extends LoginAction
{
    public function index ()
    {
        $UsersModel = D('Users');
        $users = $UsersModel->getUserList();
        $this->assign('users', $users['data']);
        $this->assign('page', $users['page']);
        $this->display();
    }
    public function add ()
    {
        if (isPost()) {
            $this->createAdd('Users');
        }
        $this->display();
    }
    public function edit ()
    {
        $id = getGet('id');
        $map['id'] = $id;
        $this->setBaseData('Users', $map, 'user');
        if (isPost()) {
            $data = array();
            $data['id'] = getPost('id');
            $data['name'] = getPost('name');
            $data['email'] = getPost('email');
            $data['pwd'] = getPost('pwd');
            $data['repwd'] = getPost('repwd');
            if ($data['pwd'] && $data['repwd']) {} else {
                unset($data['pwd']);
                unset($data['repwd']);
            }
            $rs = $this->createUpdate('Users', $data);
            if ($rs) {
                $this->setBaseData('Users', $map, 'user');
            }
        }
        $this->assign('id', $id);
        $this->display();
    }
}
?>